<extend name="Public/base" />

<block name="body">
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title cf">
        <h2>总店编辑</h2>
    </div>
    <!-- 标签页导航 ff-->
<div class="tab-wrap">
    <div class="tab-content">
	        <div id="level_style" style="background-color:#{$type.shop_color};" >
            <div id="pic">
                <img id="img_level" src="/Public/Admin/images/123.png" alt="">
            </div>
            <span id="shop_name" >{$type.name}</span>
            <span id="member_id" >NO.123456</span>
            <span id="level_number">会员积分：0</span>
        </div>
    <!-- 表单 -->
    <form id="form" action="{:U('edittype')}" method="post" class="form-horizontal">
        <div class="form-item">
            <label class="item-label">总店名称<span class="check-tips">（总店全称）</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="name" value="{$type.name}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">会员卡色值<span class="check-tips">（会员卡显示背景色）</span></label>
            # <input type="text" name="shop_color" id="picker" value="{$type.shop_color}" style=" border-right: 20px solid #{$type.shop_color};"></input>
                <!--<div class="controls">
                    <input typedd="text" class="text input-large" name="shop_color" value="">
                </div>-->
        </div>

        <div class="form-item">
                <label class="item-label">店铺logo<span class="check-tips"></span></label>
                <div class="controls">
                    <input type="file" id="upload_picture_logo">
                    <input type="hidden" name="logo" id="cover_id_logo" value="{$type.shop_logo_image}"/>
                    <div class="upload-img-box">
                        <div class="upload-pre-item"><img src="{$type.shop_logo_image|get_cover='path'}"/></div>
                    </div>
                </div>
                <script type="text/javascript">
                    //上传图片
                    /* 初始化上传插件 */
                    $("#upload_picture_logo").uploadify({
                        "height"          : 30,
                            "swf"             : "__STATIC__/uploadify/uploadify.swf",
                            "fileObjName"     : "download",
                            "buttonText"      : "上传图片",
                            "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                            "width"           : 120,
                            'removeTimeout'   : 1,
                            'fileTypeExts'    : '*.jpg; *.png; *.gif;',
                            "onUploadSuccess" : uploadPicturelogo,
                            'onFallback' : function() {
                                alert('未检测到兼容版本的Flash.');
                            }
                        });
                    function uploadPicturelogo(file, data){
                        var data = $.parseJSON(data);
                        var src = '';
                        if(data.status){
                            $("#cover_id_logo").val(data.id);
                            src = data.url || '__ROOT__' + data.path;
                            $("#cover_id_logo").parent().find('.upload-img-box').html(
                               '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                            );
                        } else {
                            updateAlert(data.info);
                            setTimeout(function(){
                                $('#top-alert').find('button').click();
                                $(that).removeClass('disabled').prop('disabled',false);
                            },1500);
                        }
                    }
                </script>
            </div>

            <div class="form-item">
                <label class="item-label">店铺会员卡图片<span class="check-tips"></span></label>
                <div class="controls">
                    <input type="file" id="upload_picture_cardimage">
                    <input type="hidden" name="cardimage" id="cover_id_cardimage" value="{$type.shop_cart_image}"/>
                    <div class="upload-img-box">
                        <div class="upload-pre-item"><img src="{$type.shop_cart_image|get_cover='path'}"/></div>
                    </div>
                </div>
                <script type="text/javascript">
                    //上传图片
                    /* 初始化上传插件 */
                    $("#upload_picture_cardimage").uploadify({
                        "height"          : 30,
                            "swf"             : "__STATIC__/uploadify/uploadify.swf",
                            "fileObjName"     : "download",
                            "buttonText"      : "上传图片",
                            "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                            "width"           : 120,
                            'removeTimeout'   : 1,
                            'fileTypeExts'    : '*.jpg; *.png; *.gif;',
                            "onUploadSuccess" : uploadPicturecardimage,
                            'onFallback' : function() {
                                alert('未检测到兼容版本的Flash.');
                            }
                        });
                    function uploadPicturecardimage(file, data){
                        var data = $.parseJSON(data);
                        var src = '';
                        if(data.status){
                            $("#cover_id_cardimage").val(data.id);
                            src = data.url || '__ROOT__' + data.path;
                            $("#cover_id_cardimage").parent().find('.upload-img-box').html(
                               '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                            );
                        } else {
                            updateAlert(data.info);
                            setTimeout(function(){
                                $('#top-alert').find('button').click();
                                $(that).removeClass('disabled').prop('disabled',false);
                            },1500);
                        }
                    }
                </script>
            </div>

            <div class="form-item">
                <label class="item-label">设为主推分类<span class="check-tips">（0：非主推  1：主推）</span></label>
                <div class="controls">
                    <input type="text" class="text input-large" name="zhutui" value="{$type.zhutui}">
                </div>
            </div>

            <div class="form-item">
                <label class="item-label">会员卡说明<span class="check-tips"></span></label>
                <label class="textarea">
                    <textarea name="shop_cart_note">{$type.shop_cart_note}</textarea>
                        {:hook('adminArticleEdit', array('name'=>"shop_cart_note",'value'=>$type['shop_cart_note']))}
                </label>
            </div>

        <div class="form-item cf">
            <input type="hidden" name="type_id" value="{$type.type_id}">
            <button class="btn submit-btn ajax-post hidden" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <a class="btn btn-return" href="javascript:history.back(-1);">返 回</a>
        </div>
    </form>
    </div>
</div>
</block>


<block name="script">
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="/Public/Admin/css/level.css" media="all">
<link rel="stylesheet" type="text/css" href="/Public/Admin/iColor/css/colpick.css" media="all">
<script src="/Public/Admin/iColor/js/colpick.js"></script>
<script type="text/javascript">
$('#submit').click(function(){
    $('#form').submit();
});
$("#type_select").change(function(){
    if($(this).val() == -1){
        $("#add_type").removeClass("hidden");
    }else{
        $("#add_type").addClass("hidden");
    }
})

$("#Headquarters").bind("blur",function(){

    var v = $(this).val();
    $("#shop_name").text(v);
    });

$('#picker').colpick({

	layout:'hex',

	submit:0,

	colorScheme:'dark',

	onChange:function(hsb,hex,rgb,el,bySetColor) {

		$(el).css('border-color','#'+hex);

		// Fill the text box just if the color was set using the picker, and not the colpickSetColor function.

		if(!bySetColor) $(el).val(hex);

	}

}).keyup(function(){

	$(this).colpickSetColor(this.value);

});
$('#picker').bind("blur",function(){
	
	var clr = $(this).val();
	var _clr = '#'+clr;
	$('#level_style').css('background-color',_clr);
});

</script>
</block>